<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<html>
<head>
<base href="<%=basePath%>" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>添加公司</title>
<script type='text/javascript' src='js/jquery-1.4.2.min.js'></script>
		<script type='text/javascript' src='js/jquery.validate.min.js'></script>
		<script type='text/javascript' src='js/common.js'></script>
<link href="manage/manage.css" rel="stylesheet" type="text/css">
<link href="images/css.css"  rel="stylesheet" type="text/css" />
<script type="text/javascript"> 
    
    function deleteCompany(delId)
	{
	 if(!confirm("您确定要删除该用户评价吗?"))
	 {
	  return;
	 }
	 document.location.href="company!delCompany.action?panyId="+delId;
	} 
	 //转至多少页码
	 function changePage(listId)
	 {
	  document.location.href="company!allCompanyListByName.action?pageNo="+listId;
	 } 
	 
	 //新增加公司
	 function xinzhengCom()
	 {
	  document.getElementById("upCom").style.display="none";
	  document.getElementById("addCom").style.display="inline";
	   document.getElementById("errSpan").style.display="none";
	 }
	 
	 //编辑显示
	 function updateCompany(updateId)
	 {
	  document.getElementById("upCom").style.display="inline";
	  document.getElementById("addCom").style.display="none";
	  document.getElementById("errSpan").style.display="none";
	  
	  var cId="cp"+updateId;
	  var cpN="cpName"+updateId;
	  
	  document.getElementById("comId").innerText=document.getElementById(cId).innerText;
	  document.getElementById("upanyName").value=document.getElementById(cpN).innerText;
	  document.getElementById("panyId").value=updateId;
	 }
	 //取消编辑
	 function quxiaoupdate()
	 {
	  document.getElementById("upCom").style.display="none";
	 }
	 
	  //取消编辑
	 function quxiaoAdd()
	 {
	  document.getElementById("addCom").style.display="none";
	 }
	 
	 //保存编辑
	 function updateCom()
	 {
	 var bgName=document.getElementById("upanyName").value;
	  if(bgName.trim()=="")
	  {
		 alert("请输入公司名称");
		return;
	  }
	  $("#updateForm").submit();
	 }
	 
	 //增加
	 function addCom()
	 {
	 var pName=document.getElementById("panyName").value;
	  if(pName.trim()=="")
	  {
	  alert("请输入公司名称");
		return;
	  }
	  $("#addForm").submit();
	 }
	</script>
<style type="text/css">
<!--
.STYLE2 {font-size: 16px}
-->
</style>
</head>
<body style="margin:0px; text-align:center;font-size:14px;" bgcolor="#F1F1F1" >
<div id="top">
 	<!-- 头部-->
 	<%@include file="mainTop.jsp"%>
</div>
<div id="top2"></div>

<!-- 中间-->
<div id="main1">
<!-- 左边-->
 <%@include file="mainLeft.jsp"%>
 <div class="mainr2">

<table width="746" height="539" border="0" cellpadding="0" cellspacing="0" bgcolor="#F1F1F1">
   <tr>
    <td width="774" height="500" align="center" valign="top" bgcolor="#FFFFFF" style="border:1px solid #C5C5C5; padding:1px ;">
    <table width="746" height="32" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="15%" align="left" background="images/sp_bg.jpg" style="border-bottom:1px solid #C5C5C5;"><img src="images/dian.jpg" width="10" height="16" /><span class="STYLE3">公司列表</span>&nbsp;&nbsp;&nbsp;<a href="javaScript:xinzhengCom();">新增公司</a></td>
        <td width="15%" align="left" background="images/sp_bg.jpg" style="border-bottom:1px solid #C5C5C5;"> &nbsp;&nbsp;&nbsp;&nbsp;</td>
     </tr>
    </table>
      <table width="93%" border="0" cellspacing="0" cellpadding="0">
      <br/>
      <tr id="errSpan">
      <td colspan="3" style="color: red;"><s:actionerror/></td>
      </tr>
       <!-- 开始数据显示 -->
        <tr style="font-size: 18px;">
          <td width="17%" height="8" align="center" background="images/lm1_bg.jpg"><span class="STYLE2">公司ID</span></td>
          <td width="55%" height="8" align="center" background="images/lm1_bg.jpg"><span class="STYLE2">公司名称</span></td> 
          <td width="28%" height="8" align="center" background="images/lm1_bg.jpg"><span class="STYLE2">操作</span></td>
        </tr>
        <s:iterator value="pageObj.data" var="comp" status="st">
        <s:if test="#st.odd"><tr bgcolor="#FFFFFF" style="font-size: 16px;"> </s:if>
        <s:else> <tr bgcolor="#CCCCCC"  style="font-size: 16px;"></s:else>
          <td width="17%" height="20" align="center" id="cp${comp.id}">${comp.id}</td>
          <td width="55%" height="20" align="center" id="cpName${comp.id}">${comp.companyName}</td> 
          <td width="28%" height="20" align="center"><a href="javaScript:updateCompany('${comp.id}');">编辑</a>|<a href="javaScript:deleteCompany('${comp.id}');">删除</a></td>
        </tr>
        </s:iterator>
		<!--编辑字段时候显示-->
		<s:form name="updateForm" id="updateForm" action="company!updateCompany.action">
		 <tr bgcolor="#99CCCC" id="upCom" style="display: none" name="upCom">
          <td width="17%" height="8" align="center" id="comId" name="comId" style="color: red;"></td>
          <td width="55%" height="8" align="center" ><input name="panyId" id="panyId" type="hidden"/><input name="upanyName" id="upanyName" size="15" style="text-align: center;"/>
          <span style="color:red" id="upCoSpan">*</span></td> 
          <td width="28%" height="8" align="center"><a href="javaScript:updateCom();">保存</a>|<a href="javaScript:quxiaoupdate();">取消</a></td>
        </tr>
        </s:form>
        
        <!--新增字段时候显示-->
		<s:form name="addForm" id="addForm" action="company!addCompany.action" method="post">
	    <tr style="display: none" id="addCom" name="addCom">
          <td width="17%" height="8" align="center" bgcolor="#99CCCC" >公司名称：</td>
          <td width="55%" height="8" align="center" bgcolor="#99CCCC" ><input name="panyName" id="panyName" size="15"/>
          <span style="color:red" id="pComSpan">*</span></td> 
          <td width="28%" height="8" align="center" bgcolor="#99CCCC"><a href="javaScript:addCom();">增加</a>|<a href="javaScript:quxiaoAdd();">取消</a></td>
        </tr>
		</s:form>
      </table>
      
        
        <s:else><p style="color: red;font-size: 12px;text-align: center;">您还没有增加相关信息!</p></s:else>
     <s:if test="pageObj.totalRecord>10">
      <table width="714" height="39" border="0" cellpadding="0" cellspacing="0" style="border-top:1px solid;">
        <tr>
          <td width="714" align="right"><a href="company!allCompanyListByName.action?pageNo=1">首页</a>&nbsp;
		   <s:if test="pageObj.hasPrePage==false" >上一页</s:if>
            <s:else> <a href="company!allCompanyListByName.action?pageNo=<s:property value="pageObj.pageNo-1"/>">上一页</a></s:else>
   
		  &nbsp;<s:if test="pageObj.hasNextPage==false">下一页</s:if>
              <s:else> <a href="company!allCompanyListByName.action?pageNo=<s:property value="pageObj.pageNo+1"/>" >下一页</a></s:else>
			  
		  &nbsp;<s:if test="pageObj.pageNo==pageObj.totalPage">末页</s:if>
		  <s:else><a href="company!allCompanyListByName.action?pageNo=<s:property value="pageObj.totalPage"/>" >末页</a></s:else>
		  
		  &nbsp;&nbsp;第${pageObj.pageNo}页&nbsp;|&nbsp;共${pageObj.totalPage}页&nbsp;|&nbsp;共${pageObj.totalRecord}条&nbsp;&nbsp;转至&nbsp;
            <s:select list="pageObj.listNum" onchange="changePage(this.value)" id="pageNo" name="pageNo">
            </s:select>
          &nbsp;</td>
        </tr>
      </table>
	 </s:if>  
	
     </td>
  </tr>
</table>
 </div>

</div>


</body>
</html>
